package com.emperor.work.logic;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.emperor.core.logic.BizModelBase;
import com.emperor.employee.logic.Employee;
import com.emperor.util.DateFormatter;

public class WorkModel extends BizModelBase implements Work {

	private Long id;
	private Employee employee;
	private String type;
	private Date punch;
	private String status;
	
	private SimpleDateFormat sdf = new SimpleDateFormat(DateFormatter.YYYYMMDD);
	
	public Long getId() {
		return id;
	}

	public void setId(Object id) {
		if (id != null) {
			if (id instanceof Long) {
				this.id = (Long) id;
			} else {
				try {
					this.id = new Long(id.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Object employee) {
		if (employee != null) {
			if (employee instanceof Employee) {
				this.employee = (Employee) employee;
			}
		}
	}

	public String getType() {
		return type;
	}

	public void setType(Object type) {
		if (type != null) {
			if (type instanceof String) {
				this.type = (String) type;
			} else {
				try {
					this.type = type.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	public Date getPunch() {
		return punch;
	}

	public void setPunch(Object punch) {
		if (punch != null) {
			if (punch instanceof Date) {
				this.punch = (Date) punch;
			} else {
				try {
					this.punch = sdf.parse(punch.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(Object status) {
		if (status != null) {
			if (status instanceof String) {
				this.status = (String) status;
			} else {
				try {
					this.status = status.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	@Override
	public List<String> getFieldNames() {
		List<String> fieldNames = new ArrayList<String>();
		
		fieldNames.add(FLD_ID);
		fieldNames.add(FLD_EMPLOYEE);
		fieldNames.add(FLD_TYPE);
		fieldNames.add(FLD_PUNCH);
		fieldNames.add(FLD_STATUS);
		
		fieldNames.add(FLD_CRTBY);
		fieldNames.add(FLD_CRTDATE);
		fieldNames.add(FLD_UPDBY);
		fieldNames.add(FLD_UPDDATE);
		
		return fieldNames;
	}

}
